package com.xbdun.comweb.bmp.session;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;

import com.xbdun.common.api.Client;

/**
 * http://blog.csdn.net/syani/article/details/52239967
* @ClassName: IUserAuth
* @Description	权限设置
* @author zhanggt 360730440@qq.com
* @date 2017年5月11日 下午9:30:27
 */
public interface IUserAuth {
	static final String USER_AUTH_MENU = "USER_AUTH_MENU";//平台用户权限
	static final String PLAT_AUTH_MENU = "PLAT_AUTH_MENU";//平台菜单
	static final String PLAT_ORG_AUTH_MENU = "PLAT_ORG_AUTH_MENU";//机构平台菜单
	/**写入缓存*/
	@CachePut(value=USER_AUTH_MENU,key="T(String).valueOf(#client.platCode).concat('-').concat(T(String).valueOf(#client.orgCode)).concat(T(String).valueOf(#client.userCode))")
	public String putInUserAuth(Client client);
	/**获取缓存*/
	@Cacheable(value=USER_AUTH_MENU,key="T(String).valueOf(#client.platCode).concat('-').concat(T(String).valueOf(#client.orgCode)).concat(T(String).valueOf(#client.userCode))")
	public String getUserAuth(Client client);
	
	/**删除缓存*/
	@CacheEvict(value=USER_AUTH_MENU,key="T(String).valueOf(#client.platCode).concat('-').concat(T(String).valueOf(#client.orgCode)).concat(T(String).valueOf(#client.userCode))")
	public void removeUserAuth(Client client);
	
	/**平台所有菜单菜单,值:xxxx^xxxx**/
	@CachePut(value=PLAT_AUTH_MENU,key="#menuKey")
	public String putInAllPlatform(String menuKey,String value);
	
	/**平台对应菜单,值:xxxx^xxxx*/
	@Cacheable(value=PLAT_AUTH_MENU,key="#menuKey")
	public String getSysPlatAuth(String menuKey);
	
	/**清楚本地系统菜单缓存*/
	@CacheEvict(value=PLAT_AUTH_MENU,allEntries=true)
	public void removePlatAuth();
	/**初始化当前平台的系统菜单，内部执行：putInAllPlatform*/
	public void initPlatform(int platCode);
	
	/**获取当前的机构权限*/
	@Cacheable(value=PLAT_ORG_AUTH_MENU,key="T(String).valueOf(#orgCode).concat('-').concat(T(String).valueOf(#platCode))")
	public String getCurrentOrgAuth(long orgCode,int platCode);
	
	/**获取当前的机构权限*/
	@CacheEvict(value=PLAT_ORG_AUTH_MENU,key="T(String).valueOf(#orgCode).concat('-').concat(T(String).valueOf(#platCode))")
	public void removeCurrentOrgAuth(long orgCode,int platCode);
}
